package com.google.code.main;

import java.util.List;

import org.dom4j.DocumentException;
import org.tanukisoftware.wrapper.WrapperListener;
import org.tanukisoftware.wrapper.WrapperManager;

//import org.apache.commons.lang3.StringEscapeUtils;

import com.google.code.robot.HeroConf;
import com.google.code.robot.Player;
import com.google.code.robot.Robot;

public class EntryPoint implements WrapperListener{
	public static final String bUrl = "http://s8.hero.9wee.com";

	public static void main(String[] args) throws Exception {
		System.out.println("Initializing...");
		WrapperManager.start(new EntryPoint(), args);
	}

	@Override
	public void controlEvent(int event) {
		System.out.println("controlEvent(" + event + ")");
	}

	@Override
	public Integer start(String[] arg0) {
		HeroConf conf = HeroConf.getInstance();
		List<Player> players;
		try {
			players = conf.getPlyaers();
			for (Player player : players) {
				new Robot(player).start();
			}
		} catch (DocumentException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public int stop(int exitCode) {
		System.out.println("stop(" + exitCode + ")");
		return exitCode;
	}
}
